
package controller;




import bo.BUS_KhachHang;
import com.opensymphony.xwork2.ActionSupport;
import dto.DTO_KhachHang;
import java.util.ArrayList;



public class QLKhachHangAction extends ActionSupport {

    private ArrayList<DTO_KhachHang>  dskh;
    private String HoTen;
    private String MatKhau;
    private int GioiTinh;
    private String DiaChi;
    private String Email;
    private String DienThoai;
    private int QuyenHan;


    private String chon;
    private String gtTimKiem;
    private String loi;

    public String getChon() {
        return chon;
    }

    public void setChon(String chon) {
        this.chon = chon;
    }

    public String getGtTimKiem() {
        return gtTimKiem;
    }

    public void setGtTimKiem(String gtTimKiem) {
        this.gtTimKiem = gtTimKiem;
    }



    public String getLoi() {
        return loi;
    }

    public void setLoi(String loi) {
        this.loi = loi;
    }




    public String getDiaChi() {
        return DiaChi;
    }

    public void setDiaChi(String DiaChi) {
        this.DiaChi = DiaChi;
    }

    public String getDienThoai() {
        return DienThoai;
    }

    public void setDienThoai(String DienThoai) {
        this.DienThoai = DienThoai;
    }

    public String getEmail() {
        return Email;
    }

    public void setEmail(String Email) {
        this.Email = Email;
    }

    public int getGioiTinh() {
        return GioiTinh;
    }

    public void setGioiTinh(int GioiTinh) {
        this.GioiTinh = GioiTinh;
    }

    public String getHoTen() {
        return HoTen;
    }

    public void setHoTen(String HoTen) {
        this.HoTen = HoTen;
    }

    public int getQuyenHan() {
        return QuyenHan;
    }

    public void setQuyenHan(int QuyenHan) {
        this.QuyenHan = QuyenHan;
    }

    public ArrayList<DTO_KhachHang> getDskh() {
        return dskh;
    }

    public void setDskh(ArrayList<DTO_KhachHang> dskh) {
        this.dskh = dskh;
    }

    public String getMatKhau() {
        return MatKhau;
    }

    public void setMatKhau(String MatKhau) {
        this.MatKhau = MatKhau;
    }



    public QLKhachHangAction() {

    }



    public String execute() throws Exception {
        
        if(chon.equals("1"))
        {

            BUS_KhachHang busKH = new BUS_KhachHang();
            int gt = Integer.parseInt(gtTimKiem);
            dskh = busKH.LayDanhSachKHTheoMaKH(gt);
        }
        if(chon.equals("2"))
        {
            BUS_KhachHang busKH = new BUS_KhachHang();
            dskh = busKH.LayDanhSachKHTheoTenKH(gtTimKiem);
        }
        if(chon.equals("3"))
        {
            BUS_KhachHang busKH = new BUS_KhachHang();
            dskh = busKH.LayDanhSachKH();
        }
        return "success";

    }

    @Override
    public void validate() {
        if(chon.equals("1"))
        {
            if(gtTimKiem.equals(""))
            {
                addActionError("Vui lòng nhập vào giá trị tìm kiếm");
                return;

            }
            try
            {
                int a = Integer.parseInt(gtTimKiem);
                
            }
            catch(Exception e)
            {
                 addActionError("Dữ liệu nhập không hợp lệ");
                 return;
            }
        }
        if(chon.equals("2"))
        {
            if(gtTimKiem.equals(""))
            {
                addActionError("Vui lòng nhập vào giá trị tìm kiếm");
                return;

            }

        }
    }



}